'''
Created on Jan 25, 2010

@author: madsk
'''

from PyQt4 import QtGui, QtCore

class SaveDialog(QtGui.QDialog):
    def __init__(self, parent=None):
        super(SaveDialog, self).__init__(parent)
        
        self._vbox = QtGui.QVBoxLayout(self)
        self.setLayout(self._vbox)

        self._vbox.addWidget(QtGui.QLabel("The image has been altered. Would you like to save these modifications?\nPress 'Done' to save modifications, 'Discard' to discard them, and 'Cancel'\nto return to the editor."))
        
        self._buttonbox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok|
                                                 QtGui.QDialogButtonBox.Cancel|
                                                 QtGui.QDialogButtonBox.Discard)
        self._vbox.addWidget(self._buttonbox)
        
        self._buttonbox.clicked.connect(self._handleButtonClicked)
        
    def _handleButtonClicked(self, button):
        if self._buttonbox.standardButton(button) == QtGui.QDialogButtonBox.Ok:
            self.done(1)
        elif self._buttonbox.standardButton(button) == QtGui.QDialogButtonBox.Cancel:
            self.done(0)
        else:
            self.done(2)